package com.yc.txx.controller;

import com.yc.bean.Result;
import com.yc.biz.BizException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(value = BizException.class)
    @ResponseBody
    public Result BizexceptionHandler(BizException e){
        System.out.println("全局异常捕获>>>:"+e);
        return new Result(-1,e.getMessage(),null);
    }
    @ExceptionHandler(value =Exception.class)
    @ResponseBody
    public Result exceptionHandler(Exception e){
        System.out.println("全局异常捕获>>>:"+e);
        return new Result(-1,"请联系管理员",null);
    }
}